**********************************************
**** Table A6:	Robustness: Worker-level Regressions
**********************************************


use "$dir/Data/analysis_main.dta", clear

egen pid1v2 = tag(pid) if !mi(hrprodpd) & pd>0 & pd<.


	eststo clear

*** Post-payment and announcement periods (2 observations per worker)
	* only baseline prod 
	eststo: reghdfe hrprodpd cash_postpay cash_announce i.pd blhrprod blhrprodsq blhrprod_miss if pd>0, vce(cl pid) absorb(roundgroup)
	test cash_postpay = cash_announce
	qui estadd scalar p_test1=r(p)
	count if e(sample) & pid1v2==1
	qui estadd scalar N2 = r(N)
	qui estadd local cont1 "Y"
	qui estadd local cont2 "N"
	qui estadd local cont3 "N"	
	qui estadd local cont4 "N"
	qui estadd local cont5 "N"		
	qui estadd local cont6 "N"
	
	* education, experience, and marital status 
	* (label each control in bottom rows of table: baseline output, education, experience, marital status)
	eststo: reghdfe hrprodpd cash_postpay cash_announce i.pd blhrprod blhrprodsq blhrprod_miss i.educ_cat exper i.marital_status if pd>0, vce(cl pid) absorb(roundgroup)
	test cash_postpay = cash_announce
	qui estadd scalar p_test1=r(p)
	count if e(sample) & pid1v2==1
	qui estadd scalar N2 = r(N)
	qui estadd local cont1 "Y"
	qui estadd local cont2 "Y"
	qui estadd local cont3 "Y"	
	qui estadd local cont4 "Y"
	qui estadd local cont5 "N"		
	qui estadd local cont6 "N"
	
	* adding in worries controls
	eststo: reghdfe hrprodpd cash_postpay cash_announce i.pd blhrprod blhrprodsq blhrprod_miss i.educ_cat exper i.marital_status loan_moneylender numloans_worry bs_labor_30_nm bs_labor_30_miss i.future_fin_worry_nm if pd>0, vce(cl pid) absorb(roundgroup)	
	test cash_postpay = cash_announce
	qui estadd scalar p_test1=r(p)
	count if e(sample) & pid1v2==1
	qui estadd scalar N2 = r(N)
	qui estadd local cont1 "Y"
	qui estadd local cont2 "Y"
	qui estadd local cont3 "Y"	
	qui estadd local cont4 "Y"	
	qui estadd local cont5 "Y"
	qui estadd local cont6 "N"
	
	* post-double selection lasso controls 
	eststo: reghdfe hrprodpd cash_postpay cash_announce i.pd blhrprod blhrprodsq blhrprod_miss bs_labor_30_miss future_fin_worry_miss if pd>0, vce(cl pid) absorb(roundgroup)
	test cash_postpay = cash_announce
	qui estadd scalar p_test1=r(p)
	count if e(sample) & pid1v2==1
	qui estadd scalar N2 = r(N)
	qui estadd local cont1 "N"
	qui estadd local cont2 "N"
	qui estadd local cont3 "N"	
	qui estadd local cont4 "N"	
	qui estadd local cont5 "N"	
	qui estadd local cont6 "Y"
	
label var cash_postpay "Cash $\times$ Post-pay" 	
label var cash_announce "Cash $\times$ Announcement period" 	
	
#delimit ;
local tablerow cash_postpay cash_announce;

esttab using "$oa/$t/Table_A6.tex", 
    cells(b(star fmt(3)) se(fmt(3) par(( ))) p(fmt(3) par([ ]))) booktabs star(* .1 ** .05 *** .01) collabels(,none) nonotes nomtitles 
    replace label style(tex) gaps keep(`tablerow') order(`tablerow') 
    stats(p_test1 cont1 cont2 cont3 cont4 cont5 cont6 N2 N, labels("P-val: Cash $\times$ Post-pay = Cash $\times$ Announcement" "Baseline output" "Education" "Experience" "Marital status" "Baseline worries controls" "Post-double selection lasso controls" "N: workers" "N: worker-periods") fmt(%9.3fc %50s %50s %50s %50s %50s %50s %9.0fc %9.0fc)) 
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} 
	\begin{tabular}     
	{@{\extracolsep{4pt}}p{9cm}*{12}{>{\centering\arraybackslash}m{2.5cm}}@{}}      \toprule     
	&\multicolumn{4}{c}{\textbf{Hourly Production}}     \bigstrut       \\ 
	\cline{2-5} \addlinespace  ") ;
		
#delimit cr	
